//
//  MeCheckBizInfo.m
//  ZITHER
//
//  Created by weixin on 2018/11/22.
//  Copyright © 2018 weixn. All rights reserved.
//

#import "MeCheckBizInfo.h"
#import "MyCheckBiz.h"
#import "MeVC.h"

@implementation MeCheckBizInfo

-(void)setModeTyep1:(MyEnquiryListDataNewModel *)modeTyep1{
    _modeTyep1 = modeTyep1;
    
    /** 添加点击事件 */
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
    
    [[tap rac_gestureSignal] subscribeNext:^(__kindof UIGestureRecognizer * _Nullable x) {
//        [Tools showTips:@"跳转商家详情"];
        MyCheckBiz *viewbiz = [MyCheckBiz defaultManager];
//        MeVC *vc = (MeVC*)[self getViewController:[MeVC class]];
//        [vc.view addSubview:viewbiz];
        viewbiz.modeTyep1 = modeTyep1;
//        [vc.tabBarController.tabBar setHidden:YES];
        
        [[UIApplication sharedApplication].keyWindow addSubview:viewbiz];
        

        
        [UIView animateWithDuration:0.2 animations:^{
            viewbiz.frame = CGRectMake(0, -20, kScreenW, kScreenH);
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:0.1 animations:^{
                viewbiz.frame = CGRectMake(0, 0, kScreenW, kScreenH);
            } completion:^(BOOL finished) {
                
            }];
        }];
        [viewbiz loadData];
    }];
        self.userInteractionEnabled = YES;
    [self addGestureRecognizer:tap];
    
    if (modeTyep1.bizInfoList.count>0) {
        self.hidden = NO;
        [self.BizPic sd_setImage: modeTyep1.bizInfoList[0].avatar];
    }else{
        self.hidden = YES;
    }
    
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.lab];
        [self addSubview:self.BizPic];
        [self addSubview:self.cover];

        [self.BizPic mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(1);
            make.centerY.equalTo(self.mas_centerY).offset(0);
            make.height.width.mas_equalTo(42);
        }];

        [self.cover mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lab.mas_right).offset(7);
            make.centerY.equalTo(self.mas_centerY).offset(0);
            make.height.mas_equalTo(10);
            make.width.mas_equalTo(5);
        }];
        
        [self.lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.BizPic.mas_right).offset(7);
            make.centerY.equalTo(self.mas_centerY).offset(0);
        }];
        
    }
    return self;
}

-(BaseLab *)lab{
    if (!_lab) {
        _lab = [[BaseLab alloc]initializeFrame:CGRectMake(0, 0, kScreenW, kScreenH) text:@"查看商家" font:18 textColor:[UIColor blackColor] isBold:NO numberOfLines:0];
        _lab.font = [UIFont fontWithName:@"PingFangSC-Medium" size:12];
        _lab.backgroundColor = [UIColor clearColor];
    }
    return _lab;
}

-(BaseImageV *)BizPic{
    if (!_BizPic) {
        _BizPic = [[BaseImageV alloc]initializeFrame:CGRectMake(0, 0, kScreenW, kScreenH) contentMode:1];
        [_BizPic setCornerRadiusWithRadius:22 isMasks:YES];
        _BizPic.backgroundColor = [UIColor clearColor];

        
    }
    return _BizPic;
}

-(BaseImageV *)cover{
    if (!_cover) {
        _cover = [[BaseImageV alloc]initializeFrame:CGRectMake(0, 0, kScreenW, kScreenH) contentMode:2];
        _cover.image = [UIImage imageNamed:@"我的_查看商家"];
        _cover.backgroundColor = [UIColor clearColor];

    }
    return _cover;
}


@end
